﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoTestCommunication_Service
{
    class DataProgress
    {
        public static float GetFloat(ushort P1, ushort P2)
        {
            int intSign, intSignRest, intExponent, intExponentRest;
            float faResult, faDigit;
            intSign = P1 / 32768;
            intSignRest = P1 % 32768;
            intExponent = intSignRest / 128;
            intExponentRest = intSignRest % 128;
            faDigit = (float)(intExponentRest * 65536 + P2) / 8388608;
            faResult = (float)Math.Pow(-1, intSign) * (float)Math.Pow(2, intExponent - 127) * (faDigit + 1);
            return faResult;
        }
        public static float GetString01(float F1)
        {
            int A = 4000, B = 20000, C = 0, D = 100;
            float faResult;
            faResult = ((F1 - A) / (B - A)) * (D - C);
            return faResult;
        }
        public static float GetString02(float F1, string S1)
        {
            float R = 0;
            //for (int I = 0; I < Access.DicAccessParameterRecord.Count; I++)
            //{
            //    if (Access.DicAccessParameterRecord[I].List_Pname == S1)
            //    {
            //        R = F1 - float.Parse(Access.DicAccessParameterRecord[I].List_Pvalue);
            //    }
            //}
            return R;
        }
        public static float GetString03(float F1)
        {
            int A = 0, B = 20000, C = 0, D = 10;
            float faResult;
            faResult = ((F1 - A) / (B - A)) * (D - C);
            return faResult;
        }
        public static float GetString04(float F1)
        {
            int A = 0, B = 20000, C = 0, D = 1;
            float faResult;
            faResult = ((F1 - A) / (B - A)) * (D - C);
            float n = (float)0.03;
            faResult += n;
            return faResult;
        }

    }
}
